package org.jeecg.modules.data.service;

import org.apache.shiro.SecurityUtils;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.modules.system.vo.ResultVo;

import java.util.ArrayList;
import java.util.List;

public class PageReturn {
    /**
     * 组合返回的信息
     * @param reqVos
     * @param pageNo
     * @param pageSize
     * @return
     */
    public ResultVo initResultVo(List reqVos, Integer count, Integer pageNo, Integer pageSize){
        ResultVo vo = new ResultVo();
        double dCount    = Double.valueOf(count);       //查询的数据总条数
        double dPageSize = Double.valueOf(pageSize);    //每页显示的条数
        int pages = (int) Math.ceil(dCount / dPageSize);//页码数量

        vo.setCurrent(pageNo);
        vo.setHitCount(false);
        vo.setOptimizeCountSql(true);
        vo.setOrders(new ArrayList<>());
        vo.setRecords(reqVos);
        vo.setPages(pages);
        vo.setSearchCount(true);
        vo.setSize(pageSize);
        vo.setTotal(count);
        return vo;
    }
}
